from selenium import webdriver
import time

#
# driver = webdriver.Chrome()           #获取对象
# driver.get("http://www.baidu.com")   #打开淘宝
# time.sleep(1)                         #延时3s
# driver.find_element_by_id('kw').send_keys('刘德华')
# time.sleep(1)
# driver.find_element_by_id('su').click()
# time.sleep(1)
# driver.find_element_by_link_text('刘德华').click()


from selenium import webdriver
from time import sleep

# driver = webdriver.Chrome()           #获取对象
# driver.get("http://192.168.13.54:8080/woniusales")   #打开蜗牛进销存
# time.sleep(1)                         #延时1s
# driver.find_element_by_id('username').send_keys('admin')
# driver.find_element_by_id('password').send_keys('admin123')
# time.sleep(6)
# driver.find_element_by_xpath('/html/body/div[4]/div/form/div[6]/button').click()
# driver.find_element_by_xpath('//*[@id="barcode"]').send_keys('6955203662897')
# time.sleep(1)
# driver.find_element_by_xpath('/html/body/div[4]/div[1]/div/div[1]/form/button').click()
# # driver.find_element_by_xpath('//*[@id="paymethod"]').click()
#
# driver.find_element_by_xpath('/html/body/div[4]/div[4]/div[1]/form/div[1]/select/option[4]').click()
# driver.find_element_by_id('submit').click()
# time.sleep(1)
# driver.switch_to.alert.accept()


# d=webdriver.Chrome()
# d.get("http://www.baidu.com")
# d.find_element_by_id("kw").send_keys("蜗牛学院")
# d.find_element_by_id("su").click()#左键单击
#
# #判断:如果标题是蜗牛学院_百度搜索，搜索成功。#获取当前标题
# time.sleep(3)
# current_title=d.title#要等一下
# print(current_title)
# if current_title=="蜗牛学院_百度搜索":
#     print('搜索成功')
# else:
#     print("搜索失败")
# time.sleep(5)#等待5秒

# d.minimize_window()
# time.sleep(1)
# d.maximize_window()
# time.sleep(1)
# d.set_window_position(300,300)
# d.set_window_size(1500,1000)
# size=d.get_window_size()
# print(size)
# d.back()
# d.forward()
# d.refresh()
# d.title



# d=webdriver.Chrome()
# d.get('http://www.baidu.com')
# cur_handle=d.current_window_handle
# print(cur_handle)
# new=d.find_element_by_xpath('//div[@id="s-top-left"]/a[1]')
# new.click()
# all_handle=d.window_handles
# print('all:',all_handle)
# sleep(2)
# print('切换前title：',d.title)
# # d.switch_to.window(window_name=all_handle[1])
# for window in all_handle:
#     if window != cur_handle:
#         d.switch_to.window(window)
# print('切换之后title：',d.title)
# sleep(3)
# d.quit()


# d=webdriver.Chrome()
# d.get('file:///E:/woniu/week4/test8.html')
# sleep(1)
# window=d.current_window_handle
# d.find_element_by_id('feiy').click()
# d.find_element_by_xpath('//*[@id="s-top-left"]/a[1]').click()
# d.find_element_by_link_text('新闻').click()
# d.find_element_by_class_name('c-color-t').click()
# # d.find_element_by_name().click()
# d.find_element_by_partial_link_text('闻').click()
# d.find_element_by_css_selector('.c-font-normal').click()
# d.find_element_by_tag_name('').click()



# d=webdriver.Chrome()
# d.get('file:///E:/woniu/week4/test8.html')
# sleep(1)
# e1=d.find_element_by_id('xinwen')
# e1.click()


# from selenium import webdriver
# from selenium.webdriver.support.wait import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# from selenium.webdriver.common.by import By
#
# d=webdriver.Chrome()
# d.implicitly_wait(5)
# d.get('localhost:8080/woniusales')
# d.find_element_by_id('username').send_keys('admin')
# d.find_element_by_id('password').send_keys('admin123')
# d.find_element_by_id('verifycode').send_keys('0000')
#
# d.find_element_by_xpath('/html/body/div[4]/div/form/div[6]/button').click()
# # e=WebDriverWait(driver=d,timeout=20).until_not(Lambda x:x.find_element_by_link_text("注销"")
# # presence_of_element_located(locator)  # 要传入的是定位方法
# outlogin=(By.LINK_TEXT,"注销")
# e=WebDriverWait(driver=d,timeout=20).until(EC.presence_of_element_located(outlogin))
# print(e.get_attribute("outerHTML"))

# 切换iframe，邮箱
# from selenium import webdriver
# from selenium.webdriver.support.wait import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# from selenium.webdriver.common.by import By
#
# d=webdriver.Chrome()
# d.implicitly_wait(5)
# d.get('https://mail.qq.com/')
# WebDriverWait(driver=d,timeout=10).until(lambda x:x.find_element_by_id('login_frame'))
# d.switch_to.frame(d.find_element_by_id('login_frame'))
# d.find_element_by_xpath("//*[@id='switcher_plogin']").click()
# d.find_element_by_id('u').send_keys('2310060039')
# # d.find_element_by_id('p').send_keys(f'{p}')
# # d.find_element_by_id('login_button').click()
#
# sleep(2)
# d.switch_to.default_content()
# d.find_element_by_link_text('企业邮箱').click()


# 鼠标
from selenium import webdriver
from selenium.webdriver.support.select import Select
import random
from selenium.webdriver.common.action_chains import ActionChains
# d=webdriver.Chrome()
# d.get('file:///E:/myhtml2/learn_1.html')
# d.get('http://192.168.13.54:8848/myhtml2/learn_1.html')

# d.implicitly_wait(10)
# s=Select(d.find_element_by_xpath('//select[@name="city"]'))
# opt=random.choice(s.options)
# s._setSelected(opt)
# print(opt.text,'被选中了')
# ActionChains(d).click_and_hold(d.find_element_by_css_selector('.bar')).move_by_offset(20,0).release().perform()

from selenium.webdriver.support.wait import WebDriverWait




# 键盘
# from selenium import webdriver
# from selenium.webdriver.common.keys import Keys
# d=webdriver.Firefox()
# d.get('http://localhost:8080/woniusales/')
#
# d.find_element_by_id('username').send_keys('admin')
# d.find_element_by_id('password').send_keys('admin123')
# d.find_element_by_id('verifycode').send_keys('0000')
# d.find_element_by_xpath('/html/body/div[4]/div/form/div[6]/button').click()
# d.find_element_by_xpath('//*[@id="barcode"]').send_keys('11111111',Keys.ENTER)
# sleep(1)
# k=d.find_element_by_xpath('//*[@id="goodslist"]/tr/td[6]/input')
# k.send_keys(Keys.CONTROL,'a')
# k.send_keys('95')



# d=webdriver.Chrome()
# d.get('file///E:\woniu\week4\drag_and_drop.html')
# d.implicitly_wait(5)
# ActionChains(d).drag_and_drop(d.find_element_by_id('drag_div1'),d.find_element_by_id('drag_div2')).perform()


from selenium.webdriver.common.keys import Keys




































